public class BruteForceSolution {
    public int searchInsert(int[] nums, int target) {
        int index = 0;
        int n = nums.length;
        if (nums[n - 1] < target) {
            return n;
        }
        for (int i = 0; i < n; i++) {
            if (nums[i] == target) {
                return i;
            }
            if (i < n - 1 && (nums[i] < target && nums[i + 1] > target)) {
                return i + 1;
            }
        }
        return 0;
    }
}
